// 导入变量和混入
@use './variables' as *;
@use './mixins' as *;

// 全局重置
* {
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: 14px;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: $font-size-base;
  line-height: $line-height-base;
  color: $text-color-primary;
  background-color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
}

// 通用工具类
.text-center {
  text-align: center !important;
}

.text-left {
  text-align: left !important;
}

.text-right {
  text-align: right !important;
}

.text-primary {
  color: $primary-color !important;
}

.text-success {
  color: $success-color !important;
}

.text-warning {
  color: $warning-color !important;
}

.text-danger {
  color: $danger-color !important;
}

.text-info {
  color: $info-color !important;
}

.text-muted {
  color: $text-color-secondary !important;
}

// 背景色
.bg-primary {
  background-color: $primary-color !important;
}

.bg-success {
  background-color: $success-color !important;
}

.bg-warning {
  background-color: $warning-color !important;
}

.bg-danger {
  background-color: $danger-color !important;
}

.bg-info {
  background-color: $info-color !important;
}

// 显示/隐藏
.d-none {
  display: none !important;
}

.d-block {
  display: block !important;
}

.d-inline {
  display: inline !important;
}

.d-inline-block {
  display: inline-block !important;
}

.d-flex {
  display: flex !important;
}

.d-inline-flex {
  display: inline-flex !important;
}

// Flex 布局
.flex-row {
  flex-direction: row !important;
}

.flex-column {
  flex-direction: column !important;
}

.flex-wrap {
  flex-wrap: wrap !important;
}

.flex-nowrap {
  flex-wrap: nowrap !important;
}

.justify-content-start {
  justify-content: flex-start !important;
}

.justify-content-end {
  justify-content: flex-end !important;
}

.justify-content-center {
  justify-content: center !important;
}

.justify-content-between {
  justify-content: space-between !important;
}

.justify-content-around {
  justify-content: space-around !important;
}

.align-items-start {
  align-items: flex-start !important;
}

.align-items-end {
  align-items: flex-end !important;
}

.align-items-center {
  align-items: center !important;
}

.align-items-baseline {
  align-items: baseline !important;
}

.align-items-stretch {
  align-items: stretch !important;
}

.flex-fill {
  flex: 1 1 auto !important;
}

.flex-grow-0 {
  flex-grow: 0 !important;
}

.flex-grow-1 {
  flex-grow: 1 !important;
}

.flex-shrink-0 {
  flex-shrink: 0 !important;
}

.flex-shrink-1 {
  flex-shrink: 1 !important;
}

// 间距
@each $prop, $abbrev in (margin: m, padding: p) {
  @each $size,
    $length
      in (
        0: 0,
        1: $spacing-extra-small,
        2: $spacing-small,
        3: $spacing-base,
        4: $spacing-medium,
        5: $spacing-large,
        6: $spacing-extra-large
      )
  {
    .#{$abbrev}-#{$size} {
      #{$prop}: $length !important;
    }
    .#{$abbrev}t-#{$size} {
      #{$prop}-top: $length !important;
    }
    .#{$abbrev}r-#{$size} {
      #{$prop}-right: $length !important;
    }
    .#{$abbrev}b-#{$size} {
      #{$prop}-bottom: $length !important;
    }
    .#{$abbrev}l-#{$size} {
      #{$prop}-left: $length !important;
    }
    .#{$abbrev}x-#{$size} {
      #{$prop}-left: $length !important;
      #{$prop}-right: $length !important;
    }
    .#{$abbrev}y-#{$size} {
      #{$prop}-top: $length !important;
      #{$prop}-bottom: $length !important;
    }
  }
}

// 边框
.border {
  border: $border-base !important;
}

.border-top {
  border-top: $border-base !important;
}

.border-right {
  border-right: $border-base !important;
}

.border-bottom {
  border-bottom: $border-base !important;
}

.border-left {
  border-left: $border-base !important;
}

.border-0 {
  border: 0 !important;
}

.border-top-0 {
  border-top: 0 !important;
}

.border-right-0 {
  border-right: 0 !important;
}

.border-bottom-0 {
  border-bottom: 0 !important;
}

.border-left-0 {
  border-left: 0 !important;
}

// 圆角
.rounded {
  border-radius: $border-radius-base !important;
}

.rounded-sm {
  border-radius: $border-radius-small !important;
}

.rounded-lg {
  border-radius: $border-radius-large !important;
}

.rounded-circle {
  border-radius: 50% !important;
}

.rounded-0 {
  border-radius: 0 !important;
}

// 阴影
.shadow-sm {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.shadow {
  box-shadow: $box-shadow-base !important;
}

.shadow-lg {
  box-shadow: $box-shadow-light !important;
}

.shadow-none {
  box-shadow: none !important;
}

// 文本省略
.text-truncate {
  @include ellipsis(1);
}

.text-truncate-2 {
  @include ellipsis(2);
}

.text-truncate-3 {
  @include ellipsis(3);
}

// 响应式工具类
@include respond-to(xs) {
  .d-xs-none {
    display: none !important;
  }
  .d-xs-block {
    display: block !important;
  }
  .d-xs-flex {
    display: flex !important;
  }
}

@include respond-to(sm) {
  .d-sm-none {
    display: none !important;
  }
  .d-sm-block {
    display: block !important;
  }
  .d-sm-flex {
    display: flex !important;
  }
}

@include respond-to(md) {
  .d-md-none {
    display: none !important;
  }
  .d-md-block {
    display: block !important;
  }
  .d-md-flex {
    display: flex !important;
  }
}

@include respond-to(lg) {
  .d-lg-none {
    display: none !important;
  }
  .d-lg-block {
    display: block !important;
  }
  .d-lg-flex {
    display: flex !important;
  }
}

@include respond-to(xl) {
  .d-xl-none {
    display: none !important;
  }
  .d-xl-block {
    display: block !important;
  }
  .d-xl-flex {
    display: flex !important;
  }
}

// 业务组件样式
// 卡片头部通用样式
.card-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: $spacing-large !important;
}

.page-container {
  padding: $spacing-large;
  min-height: calc(100vh - 60px);
  background-color: $background-color-base;

  @include respond-to(xs) {
    padding: $spacing-base;
  }
}

.page-header {
  @include center-vertical;
  justify-content: space-between;
  margin-bottom: $spacing-large;
  padding: $spacing-medium 0;
  border-bottom: 1px solid $border-color-lighter;

  .page-title {
    font-size: $font-size-extra-large;
    font-weight: $font-weight-medium;
    color: $text-color-primary;
    margin: 0;
  }

  .page-actions {
    @include center-vertical;
    gap: $spacing-base;
  }
}

.content-card {
  @include card;
  margin-bottom: $spacing-large;

  .card-header {
    @include center-vertical;
    justify-content: space-between;
    padding-bottom: $spacing-medium;
    margin-bottom: $spacing-medium;
    border-bottom: 1px solid $border-color-lighter;

    .card-title {
      font-size: $font-size-medium;
      font-weight: $font-weight-medium;
      color: $text-color-primary;
      margin: 0;
    }
  }

  .card-body {
    padding: 0;
  }
}

.search-form {
  @include card;
  margin-bottom: $spacing-large;

  .search-row {
    @include center-vertical;
    gap: $spacing-medium;
    flex-wrap: wrap;
  }

  .search-item {
    @include center-vertical;
    gap: $spacing-small;
    min-width: 200px;

    .search-label {
      white-space: nowrap;
      font-weight: $font-weight-medium;
      color: $text-color-regular;
    }
  }

  .search-actions {
    @include center-vertical;
    gap: $spacing-base;
    margin-left: auto;
  }
}

// 状态标签样式
.status-tag {
  &.status-success {
    @include status-tag('success');
  }

  &.status-warning {
    @include status-tag('warning');
  }

  &.status-danger {
    @include status-tag('danger');
  }

  &.status-info {
    @include status-tag('info');
  }

  &.status-default {
    @include status-tag('default');
  }
}

// 加载状态
.loading-container {
  @include center;
  min-height: 200px;

  .loading-spinner {
    @include loading-spinner();
  }
}

// 空状态
.empty-container {
  @include center;
  flex-direction: column;
  min-height: 200px;
  color: $text-color-secondary;

  .empty-icon {
    font-size: 48px;
    margin-bottom: $spacing-medium;
    opacity: 0.5;
  }

  .empty-text {
    font-size: $font-size-base;
  }
}

// 表格增强样式
.enhanced-table {
  .el-table {
    .cell {
      @include ellipsis(1);
    }
  }

  .table-actions {
    @include center-vertical;
    gap: $spacing-small;
  }

  .action-button {
    padding: 2px 8px;
    font-size: $font-size-small;
    border-radius: $border-radius-small;
  }
}

// 搜索组件样式
s.search-input,
.search-select {
  width: 200px;
}

// 分页容器样式
.pagination-container {
  display: flex !important;
  justify-content: flex-end !important;
  margin-top: $spacing-large !important;
}

// 表格单元格样式
.cell-ellipsis {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

// 表格操作列样式
.table-action-column {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

// 表单增强样式
.enhanced-form {
  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: $spacing-medium;

    @include respond-to(xs) {
      grid-template-columns: 1fr;
    }
  }

  .form-actions {
    @include center-vertical;
    gap: $spacing-base;
    padding-top: $spacing-large;
    border-top: 1px solid $border-color-lighter;
    margin-top: $spacing-large;
  }
}
